package com.lanlian.cayman.adapter;

import android.content.Context;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lanlian.cayman.R;
import com.lanlian.commonlib.bean.DocumentaryInfo;

import java.util.List;

/**
 * <pre>
 *     author : huxiaobo
 *     e-mail : huxiaobo@xlanlian.com
 *     date   : 2018/8/15 16:55
 *     desc   : 交易我的跟单Adapter
 *     version: 1.0
 * </pre>
 */
public class TradeDocumentaryAdapter extends BaseQuickAdapter<DocumentaryInfo, BaseViewHolder> {

    public TradeDocumentaryAdapter(Context context, int layoutResId, @Nullable List<DocumentaryInfo> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, DocumentaryInfo item) {
        helper.setBackgroundColor(R.id.lay_position, (helper.getLayoutPosition() + 1) % 2 == 0 ?
                mContext.getResources().getColor(R.color.color_bg_text_view_style2) :
                mContext.getResources().getColor(R.color.color_bg_text_view_style3));
        helper.setText(R.id.tv_name, item.getFollowRealName())
                .setText(R.id.tv_user_id, item.getFollowedNo().toString())
                .setText(R.id.tv_contract_name, "*".equals(item.getContractName()) ? "全部" : item.getContractName())
                .setText(R.id.tv_contract_code, "*".equals(item.getFutureCode()) ? "全部" : item.getFutureCode())
                .setText(R.id.tv_price, item.getFollowType() == 1 ? "市价" : String.format("超价%s", item.getFollowNum().toString()))
                .setText(R.id.tv_direction, item.getOrderDirection() == 1 ? "正向" : "反向")
                .setText(R.id.tv_type, item.getHandType() == 1 ? "倍数" : "手数")
                .setText(R.id.tv_amount, item.getHandNum().toString());
    }

}
